import { request } from "../utils/request";
import {flow} from 'mobx';
import {save} from '../utils/Storage';
class UserStore {
    userInfo: any;
    reqestLogin = flow(function* (
        this: UserStore,
        phone: string,
        pwd: string,
        callback:(success:boolean)=> void
    ){
        try{
            const params = {
                name: phone,
                pwd:pwd
            }
            const {data} = yield request("login", params);
            if (data){
                save('userInfo', JSON.stringify(data));
                this.userInfo = data;
                callback?.(true);

            }
        }catch (error){
            callback?.(false);
            this.userInfo = null;
        }

    })
}
//导出单例
export default new UserStore();